package mybatis.hr.dao;

import mybatis.hr.domain.Employee;
import mybatis.hr.util.DatabaseManager;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

public class EmployeeDAO {
	private static EmployeeDAO instance = new EmployeeDAO();
	
	private SqlSessionFactory factory;
	
	private EmployeeDAO(){
		factory = DatabaseManager.getInstance().getSqlSessionFactory();
	}
	public static EmployeeDAO getInstance(){
		return instance;
	}
	
	public Employee selectEmployeeById(String employeeId){
		SqlSession session = factory.openSession();
		
		try{
			return session.selectOne("hr.employee.selectEmployeeById", employeeId);
		}finally{
			session.close();
		}
	}
}
